﻿#region copyright
//<copyright>
// Copyright(C) 2012 TrackerRealm Corporation
// This file is part of the open source project - Jazz. http://jazz.codeplex.com
// 
// Jazz is open software: you can redistribute it and/or modify it 
// under the terms of the GNU Affero General Public License (AGPL) as published by 
// the Free Software Foundation, version 3 of the License.
// 
// Jazz is distributed in the hope that it will be useful, 
// but WITHOUT ANY WARRANTY; without even the implied warranty 
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
//  See the GNU Affero General Public License (AGPL) for more details.
// 
// You should have received a copy of the GNU General Public 
// License along with Jazz.  If not, see <http://www.gnu.org/licenses/>.
//
// REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT. 
//</copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Reflection;
using TrackerRealm.Jazz.Common;
using C = TrackerRealm.Jazz.Common.JazzConstants;
using TrackerRealm.Jazz.Client;


namespace TrackerRealm.Jazz.Client.Custom
{
    /// <summary>
    /// 
    /// </summary>
    public class NexusConfig: NexusConfigBase
    {
        #region Static members
        /// <summary>
        /// 
        /// </summary>
        public static NexusConfig DefaultSettings()
        {
            return new NexusConfig();
        }
        /// <summary>
        /// Use this 'NexusConfig' instance to have actions performed by Jazz will be written to the console.
        /// <para>This feature can only be activated when the 'Jazz' is compiled with the 'DEBUG' compiler constant defined.</para>
        /// <para>This feature is useful when debuging Jazz applications.</para>
        /// </summary>
        public static NexusConfig DefaultVerbose()
        {
            return new NexusConfig() { Verbose = VerboseType.All };
        }
        #endregion
        #region Constructor
        /// <summary>
        /// Constructor
        /// </summary>
        public NexusConfig()
        {
            base._LoginProfile = jUser.Create(C.GUEST);
            this.PublicWorkspace = new Tuple<jWorkspace, jWorkspace>(
                jWorkspace.Create(C.WORKSPACE_PUBLIC),
                jWorkspace.Create(C.WORKSPACE_EMPTY));
        }
        #endregion
        //
        // Instance members
        //
        #region LoginUser
        /// <summary>
        /// <para>This is the profile that will be the logged in when the nexus is created.</para>
        /// <para>If no LoginProfile is specified a 'Guest' user, and default profile, will be created.</para>
        /// </summary>
        public jProfile LoginProfile
        {
            get { return (jProfile)base._LoginProfile; }
            set
            {
                base._LoginProfile = value;
            }
        }
        #endregion
        #region PublicWorkspace
        /// <summary>
        /// The public workspace object used by client nexus.  If the property '<see cref="NexusConfigBase.BindUnits"/>' contains
        /// the public workspace this property is not used.
        /// <para>
        /// The first item must be public workspace and 2nd item of the must be the empty workspace.</para>
        /// <para>Note: This property will be ignored if the property 'StorageObjects' contains a public workspace.</para>
        /// </summary>
        public Tuple<jWorkspace, jWorkspace> PublicWorkspace
        {
            set
            {
                if(value.Item1.ACL.Count() > 0)
                    throw new ArgumentException("The 'Public' workspace is not allowed to have an non-empty ACL.");
                base._PublicWorkspace = new Tuple<jWorkspaceBase, jWorkspaceBase>(value.Item1, value.Item2);
            }
            get {return  new Tuple<jWorkspace, jWorkspace>((jWorkspace)base._PublicWorkspace.Item1, (jWorkspace)base._PublicWorkspace.Item2); }
        }
        #endregion
    }
}
